<template>
  <view class="yg-top"
        v-show="showBackToTop"
        @click="goTop()">
    顶部
  </view>
</template>

<script>
export default {
  data() {
    return {
      showBackToTop: false,
    }
  },
  methods: {
    goTop() {
      uni.pageScrollTo({
        scrollTop: 0,
        duration: 300,
      })
    },
  },
}
</script>

<style lang="scss" scoped>
.yg-top {
  position: fixed;
  background-color: #eb4450;
  width: 80rpx;
  height: 80rpx;
  border-radius: 50%;
  line-height: 80rpx;
  text-align: center;
  color: white;
  bottom: 10rpx;
  right: 10rpx;
}
</style>
